<script type="text/html" template lay-done="layui.data.sendParams(d.params)"></script>
<style>
    .mapBox1 {
        position: static !important;
        transform: none !important;
    }
</style>
<div id="mapBox1" class="mapBox1"></div>
<script>
    var map = null;
    var setPoint = false;
    console.log("===============================")

    function init() {
        console.log("----------------init----------------")
        var myLatLng = new qq.maps.LatLng(39.916527, 116.397128);
        var myOptions = {
            zoom: 8,
            center: myLatLng,
            mapTypeId: qq.maps.MapTypeId.ROADMAP
        }
        map = new qq.maps.Map(document.getElementById("mapBox1"), myOptions);
        console.log("----------------init----------------")
    }

    //异步加载地图库函数文件
    function loadScript() {
        console.log("----------------===loadScript===----------------")
        var script = document.createElement("script");
        script.type = "text/javascript";
        script.src = "https://map.qq.com/api/js?v=2.exp&key=EXIBZ-KDFL6-6T5SD-ML3J2-WDDO7-YZFVW&callback=init";
        document.body.appendChild(script);
        console.log("----------------===loadScript===----------------")
    }

    console.log("===============================")
</script>
<script>
    layui.data.sendParams = function (params) {
        layui.use(['admin', 'form', 'setter', 'table', 'laytpl'], function () {
            var $ = layui.$
                , laytpl = layui.laytpl
                , setter = layui.setter;

            console.log("================111===============")
            var apiUrl = setter.apiUrl;
            console.log(params);
            loadScript();
            var startLocation = params.startLocation;
            var pointArr = startLocation.split(',');
            var pointArr1 = startLocation.split(',');
            var timer = setTimeout(function () {
                console.log("================222===============")
                if (setPoint) {
                    console.log("================444===============")
                    clearTimeout(timer);
                }
                if (map != null) {
                    console.log("================333===============")
                    map.panTo(new qq.maps.LatLng(pointArr[0], pointArr[1]));
                    var center = new qq.maps.LatLng(pointArr[0], pointArr[1]);
                    var center1= new qq.maps.LatLng(pointArr1[0], pointArr1[1]);

                    var marker = new qq.maps.Marker({
                        position: center,
                        map: map
                    });
                    var marker1 = new qq.maps.Marker({
                        position: center1,
                        map: map
                    });

                    marker.setMap(map);
                    marker.setVisible(true);
                    marker1.setMap(map);
                    marker1.setVisible(true);
                    setPoint = true;
                    console.log("================333===============")
                }
                console.log("================222===============")
            }, 2000);
            console.log(pointArr);
            console.log("================111===============")
        })
    };
</script>